/*******************************************************************************
 * Copyright (c) 2010 Torkild U. Resheim
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     Torkild U. Resheim - initial API and implementation
 *******************************************************************************/
package no.resheim.buildmonitor.ui.log;

import java.lang.reflect.InvocationTargetException;

import no.resheim.buildmonitor.core.data.Job;

import org.eclipse.compare.CompareConfiguration;
import org.eclipse.compare.CompareEditorInput;
import org.eclipse.compare.structuremergeviewer.DiffNode;
import org.eclipse.core.resources.IStorage;
import org.eclipse.core.runtime.IProgressMonitor;

public class LogCompareInput extends CompareEditorInput {

	private final Job job;
	private final int left;
	private final int right;

	public LogCompareInput(CompareConfiguration configuration, Job job,
			int left, int right) {
		super(configuration);
		this.job = job;
		this.left = left;
		this.right = right;
	}

	@Override
	protected Object prepareInput(IProgressMonitor monitor)
			throws InvocationTargetException, InterruptedException {
		IStorage leftLog = job.getLog(left);
		IStorage rightLog = job.getLog(right);
		return new DiffNode(new LogInput(leftLog), new LogInput(rightLog));
	}
}
